package com.example.service.webhook.business.bank.repository;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.example.service.webhook.business.bank.entity.BankBillInstallmentEntity;
import com.example.service.webhook.repository.base.BaseDAO;
import com.example.service.webhook.util.DateUtil;
/**
 * 
 * ClassName: BankBillInstallmentRepository    
 * date: 2017年3月20日 下午8:40:26   
 * @author yuandong  
 * @version   
 * @since JDK 1.6
 */
@Repository
public class BankBillInstallmentRepository extends BaseDAO<BankBillInstallmentEntity>{
	
	@Resource(name="templateBank")
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}
    
   
    
    public void saveBillInstallment(BankBillInstallmentEntity entity,String userId) throws Exception  {
    	entity.setCreateTime(DateUtil.getCurrentDate());
    	entity.setLastModifyTime(DateUtil.getCurrentDate());
		this.saveAndReturnKey(entity,getTableName(userId));
    }
    
    public void deleteBillInstallmentByBillId(String billId,String userId){
    	String sql = "delete from "+getTableName(userId)+" where billId=?";
    	this.delete(sql, new Object[]{billId});
    }
    
    
    private String getTableName(String userId){
    	return "t_installment";
    }
}
